package com.yksj.healthtalk.ui.home;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;

import com.yksj.healthtalk.comm.BaseFragmentActivity;
import com.yksj.healthtalk.ui.R;
import com.yksj.healthtalk.utils.SystemUtils;
import com.yksj.healthtalk.utils.ToastUtil;

public class WithdrawingMessageActivity extends BaseFragmentActivity implements OnClickListener{
	
	private EditText et;
	private String message;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.withdrawing_message);
		initWidget();
		initData();
	}

	private void initData() {
		titleLeftBtn.setText(R.string.back);
		titleRightBtn.setVisibility(View.VISIBLE);
		titleRightBtn.setBackgroundResource(R.drawable.banner_red);
		titleRightBtn.setTextColor(Color.WHITE);
		titleRightBtn.setText(R.string.sure);
		titleTextV.setText(R.string.withdrawing_registration);
		titleTextV.setTextColor(Color.BLACK);
		title.setBackgroundResource(R.drawable.setting_title_bg);
		
	
		if (getIntent().hasExtra("message")) {
			message = getIntent().getStringExtra("message");
			et.setText(message);
		}
	}

	private void initWidget() {
		initTitle();
		et = (EditText)findViewById(R.id.message);
		titleLeftBtn.setOnClickListener(this);
		titleRightBtn.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.title_back:
//			onBackPressed();
			SystemUtils.hideSoftBord(this, et);
			finish();
			break;
		case R.id.title_right:
			if (et.getText().toString().length() > 200) {
				ToastUtil.showShort(getApplicationContext(), "您好,退号原因长度需少于200.");
				return;
			}
			SystemUtils.hideSoftBord(this, et);
			Intent intent = getIntent();
			intent.putExtra("message", et.getText().toString().trim());
			setResult(RESULT_OK, intent);
			finish();
			break;
		default:
			break;
		}
	}
	

}
